# insert your desired path in the parenthesis and remove the #
# setwd("/your/working/directory/goes/here") Lab 2
DATA 202 - Alexander - Fall 2024
For Lab 2, you may submit your solutions to Canvas as a .pdf or an RMarkdown.
Please see the Preparing Lab Reports at the bottom of the lab 1 assignment.
Learning Objectives
The Lab 2 assignment focuses on you exploring any three or more variables, of which data can come from anywhere. You can use data located in one of the data frames in the critstats package or in gss_cat, or a data set that you have identified and would like to explore. You will also return to some of the functions we have used before to clean variables and manipulate data frames. Your analyses in this lab should focus on a bivariate analysis between two categorical variables, two numeric variables, or one numeric variable and one categorical variable.
Learning Activities
By the end of this lab you will be able to:
- Locate data; okay to use data sets in the
critstatspackage, or usegss_cat - Develop an original research question
- Clean and manipulate data for analysis
- Examine the relationship between three or more variables
You should submit your final output on Canvas here.
Part 0: Pre-lab tasks
Create a new RMarkdown in your
statsprojectCheck your working directory
Write a preamble
Install and/or update packages and load libraries
Task 0.1: Create a new RMarkdown
In your R session, navigate to: File > New File > R Markdown. Create a new markdown file using an appropriate title.
Task 0.2: Check your working directory
Check your working directory by typing getwd().
If you are not in the desired directory, you can change your directory using the associated path. This path should be the same as the project folder that you plan to work out of for the next several weeks.
You can add a new sub-folder manually or under the Files tab in the RStudio IDE.
Task 0.3: Write a preamble
## Name: <include your full name>
## Assignment: Lab 2
## Date: <here you may want to add a date>
## Purpose: <insert the goals or purpose of the RScript>Task 0.4: Packages and libraries
# install the tidyverse package
install.packages("tidyverse", repos = "http://cran.us.r-project.org")
# load the libraries needed for today's analyses
library(tidyverse)
library(dplyr)
library(critstats)
## update packages if needed; remove # to run code
# update.packages("package-name")Part 1:
In this part of the lab, you should complete the following tasks:
- Locate a data sets in the
critstatspackage or usegss_cat
library(critstats)
data(package = 'critstats')Recall that you can also use the
data(package="critstats")command, with a double asterisk, to see a list of data sets in the `critstats’ packageDevelop an original research question on two variables in your data set
Part 2:
In this part of the lab, you should complete the following tasks:
Clean and manipulate your data for analysis
Examine the relationship between two variables
Part 1 Reports
Report 1.1
What data set have you decided to use?
Report 1.2
Which variables from your data set will be analyzed?
Report 1.3
What is your research question?
Report 1.4
What is your data analysis plan? Please be descriptive.
Report 1.5
What are some potential limitations for your analysis?
Part 2 Reports
Report 1.6
Does your data contain missing values? If so, how have you dealt with these values?
Report 1.7
Please include all code used to clean and manipulate the variables.
Report 1.8
What relationship, if any, exists between the two variables?
Report 1.9
How do these findings relate to your research question and theory?
Report 1.10
What limitations exist as a result of the data analysis?
Experiencing issues?
If you experience issues executing your code, it is likely that you have made an error in the previous steps.
Remember that R is case sensitive in all instances, and space sensitive in some instances.
Please be sure to go back and carefully check your code.